Visual Basic (Declaration) | |
---|---|
Public Function New( _ ByVal items As IEnumerable(Of T), _ ByVal comparer As IComparer(Of T) _ ) |
C# | |
---|---|
public SetList<T>( IEnumerable<T> items, IComparer<T> comparer ) |
Parameters
- items
- comparer
Library/Library.Test/TestSetList.cs
C# | Copy Code |
---|---|
SetList<string> list = new SetList<string>((IEnumerable<string>)new string[] { "a", "B" }); Assert.AreEqual("a,B", String.Join(",", list.ToArray())); list = new SetList<string>(2); Assert.AreEqual("", String.Join(",", list.ToArray())); list.Add("a"); list.Add("B"); Assert.AreEqual("a,B", String.Join(",", list.ToArray())); list = new SetList<string>(2, StringComparer.Ordinal); Assert.AreEqual("", String.Join(",", list.ToArray())); list.Add("a"); list.Add("B"); Assert.AreEqual("B,a", String.Join(",", list.ToArray())); list = new SetList<string>(2, StringComparer.OrdinalIgnoreCase); list.Add("a"); list.Add("B"); Assert.AreEqual("a,B", String.Join(",", list.ToArray())); list = new SetList<string>(new string[] { "B", "a" }, StringComparer.Ordinal); Assert.AreEqual("B,a", String.Join(",", list.ToArray())); list = new SetList<string>((IEnumerable<string>)new string[] { "B", "a" }, StringComparer.OrdinalIgnoreCase); Assert.AreEqual("a,B", String.Join(",", list.ToArray())); |
VB.NET | Copy Code |
---|---|
Dim list As New SetList(Of String)(DirectCast(New String() {"a", "B"}, IEnumerable(Of String))) Assert.AreEqual("a,B", [String].Join(",", list.ToArray())) list = New SetList(Of String)(2) Assert.AreEqual("", [String].Join(",", list.ToArray())) list.Add("a") list.Add("B") Assert.AreEqual("a,B", [String].Join(",", list.ToArray())) list = New SetList(Of String)(2, StringComparer.Ordinal) Assert.AreEqual("", [String].Join(",", list.ToArray())) list.Add("a") list.Add("B") Assert.AreEqual("B,a", [String].Join(",", list.ToArray())) list = New SetList(Of String)(2, StringComparer.OrdinalIgnoreCase) list.Add("a") list.Add("B") Assert.AreEqual("a,B", [String].Join(",", list.ToArray())) list = New SetList(Of String)(New String() {"B", "a"}, StringComparer.Ordinal) Assert.AreEqual("B,a", [String].Join(",", list.ToArray())) list = New SetList(Of String)(DirectCast(New String() {"B", "a"}, IEnumerable(Of String)), StringComparer.OrdinalIgnoreCase) Assert.AreEqual("a,B", [String].Join(",", list.ToArray())) |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
SetList<T> ClassSetList<T> Members
Overload List